Scripting MacPGP Control The following is the syntax for handlers defined within the MPGPC application for use by external scripts: • MPGPC_ShowClipboard () Shows the MPGPC clipboard window if it's not already displayed. • MPGPC_HideClipboard () The reverse of the previous action. • MPGPC_Preferences () Invokes the Preferences dialog and allows editing of MPGPC preferences. The MPGPC preferences themselves are grouped and saved as an AppleScript script object. They look like so: property p_ExpandTabs : true -- if true replace Tab characters by spaces property p_TabLength : 5 -- default number of spaces to replace each Tab character property p_Transliterate : true -- if true apply transliteration to message before further processing it property p_TransTable : 1 -- if = 1 use 1…1 transliteration table, if = 2 use 1…many transliteration table property p_wrapPGP : true -- if true wrap message before further processing it property p_wrapLineLength : 80 -- default maximum line length when wrapping message for clear signing property p_signPGP : true -- RESERVED DO NOT TOUCH property p_UserName : "" -- default user ID property p_how2Sign : 1 -- if = 1 clear sign, if = 2 sign opaque, if = 3 sign separate property p_ICsign : true -- if true include email signature at bottom of message property p_KeyServer : "pgp-public-keys@pgp.ai.mit.edu" -- hostname to mail GET requests to property p_useHTTP : true -- if true try to connect thru TCP/IP, else mail a GET request property p_HTTPserver : "www-swiss.ai.mit.edu" -- hostname of an HTTP aware PGP keyserver property p_KeyringFile : "" -- pathname of keyring or addressbook file used in Sign/Encrypt dialog property p_KeyringDate : current date -- modification date as last seen for p_KeyringFile when scanned property p_KeyringKeys : {} -- list of key info last scanned in p_KeyringFile property p_AutoMove : false -- if true move received PGP mail to p_PGPmailbox property p_PGPmailbox : "" -- pathname of special mailbox to move PGP mail to property p_AutoDecrypt : true -- NOT YET IMPLEMENTED property p_SaveMessage : true -- If true then save message else queue it The MPGPC Preferences file is written back at quitting time. The first time it's created (when no “MPGPC Preferences” file is found in the Preferences folder inside the active System folder) its type is changed to “PREF” and its creator to MPGPC (signature “TGD2”). • MPGPC_EditTT () Invokes the Edit Transliteration Table to allow editing of the 1…many transliteration table. A 1…many transliteration table when saved to disk has a file type of “TTbl” and its creator set to “TGD2” (MPGPC's signature). • MPGPC_Conventional () Invokes the Conventional Encrypt dialog and allows conventional encryption of a file. • MPGPC_MakeCertificate () Invokes a standard choose file which when selected will generate a spearate signature certificate. The name and location of the certificate will be done through a standard choose file dialog as well. • MPGPC_Asciify () Invokes a standard choose file dialog which when selected will be asciified and its name appended with an “.asc” extension. • MPGPC_Process1Object (f: anything) The action executed will depend on the class of the object whose reference is passed at the time of the call. The general algorithm of this handler looks like this: if f's class is file or alias then -- it's a file or a folder if it's a folder then process all of the folder contents an object at a time else if it's a file of type "clpt" then -- process a text clipping extract the first TEXT resource and act upon it depending on the set behaviour else if it's a file of type "TEXT" then -- it's a text file read the file and process its contents depending on the set behaviour else if it's and addressbook file then invoke addressbook management else if it's a PGP public keyring file then invoke keyring management else tell MacPGP to open the file else if f's class is string or text then -- it's a text clipping drag-dropped directly act on f depending on the set behaviour else signal error • MPGPC_ShredFile (f: string) Tests to see if a Finder object with a pathname of f exists. If it does it's wiped by MacPGP. • MPGPC_GetClipboard () Returns a string representation of the current contents of MPGPC clipboard. • MPGPC_PutClipboard (d: anything) If d's class is a string or a text, then the contents are placed in MPGPC's clipboard. The clipboard window if opened at the time is refreshed. • MPGPC_Decrypt (m: string) Returns an empty string if unsuccessful, otherwise an AppleScript string object of the following form: theBefore & return & ¬ "- ----BEGIN PGP DECIPHERED MESSAGE----" & return & ¬ theMessage & return & ¬ "- ----END PGP DECIPHERED MESSAGE----" & return & ¬ theAfter Where: theBefore is the text object before the PGP Headerline Header (§ PGP Message Exchange Formats Internet-Draft), theMessage is the deciphered PGP message, and theAfter is the text object after the PGP Headerline Tail. Addressbook record structures The addressbook file is a dBAS file type generated by GTQ's Object Database osax (© Gregory T. Quinn), but with a MPGPC creator type. dBAS files have mainly two fields: a key field and data object field. Two kinds of records are saved in such MPGPC dBAS files: User and Group records. Both have a 32-character long key field with case and diacritical sensitive characters allowed. The difference between the two kinds of records resides in the structure of their data object part. • User data object structure The user data object is an AppleScript record of the following form: «class P@NN»: string -- 32-character max. copy of the key field = record nickname «class P@RN»: string -- real name of the user «class P@KI»: string -- 8-character key ID assigned by MacPGP to the key «class P@KF»: string -- pathname of the keyring file last seen to contain this key «class P@N1»: integer -- index (starts with 1) of the first byte of the Key Certificate Packet in keyring file for this key «class P@UI»: string -- primary user ID of the key's owner «class P@EM»: string -- email address of the key's owner «class P@**»: string -- comment field • Group data object structure The group data object is an AppleScript record of the following form: «class P@NN»: string -- 32-character max. copy of the key field = record nickname «class P@ML»: list -- list of 0, 1 or more user nicknames for the current members of this group «class P@**»: string -- comment field Known bugs/oddities • When editing a new message in Eudora, either through a New Message… or a Reply… action, and then selecting an Encrypt-Sign action in MPGPC, the latter will not be able to get this new message; instead it will select the next one down in the Eudora's window layers, or the selected message in the selected mailbox window if the new message was in the only window opened at the time. The workaround to this is to save the message (by closing it), select it and then call/click the Encrypt-Sign script/button. • In low memory situations, or/and when you open more than one keyring/addressbook management windows, MPGPC will report an error but continues to process the request. The end result in such cases is not the complete contents of the file/object being processed. The workaround to this is to allocate more RAM to MPGPC. • In PGP® Dataskope window, time information for PGP packets does not always coincide with that reported by MacPGP. The date is aways the same though. • The Edit menu items are not handled by MPGPC, instead it's left to FaceSpan to deal with them. This does not yield to a consistent behaviour across the fields and objects of the application and its windows. • The font/size used for the Message area in the Sign/Encrypt dialog is as mentioned earlier Monaco/10-point. Some characters, although are present in the text stream, become invisible and are replaced by a space. This is due to the fact that the bitmap resource for this font at this point size does not include a visual representation for these characters. If MPGPC survives PGP 3.0, I'll design a 10-point font that will eliminate this “feature.” • When an abnormal termination/shutdown of the system occurs, the next time the MPGPC application is launched it might generate a "-39: File Not Found" error. If this happens, you'll notice that the Minimum and Preferred size fields in the application's information window display ridiculously low values that you cannot change. This indicates that the MPGPC application file became corrupted. You should trash this file and install a fresh copy of the application. • MPGPC is reported not to co-habit well with Aaron 1.1.2. • On some new PowerMacs, if you quit Eudora before MPGPC, a bomb occurs; otherwise if MPGPC is terminated first, everything is fine. This looks like a FaceSpan problem, or more precisely a problem that SDU (publishers of FaceSpan) are in a position to solve either by themselves or in consort with Qualcom (publishers of Eudora). A bug report was filed with SDU.